import time
import Consensus
import SDK
from TxPool import TxPool
import Storage

i = 0
Pool = TxPool()
Chain = Storage.BlockChain()
while True:
    Tx = SDK.generate(i)
    SDK.push_to_pool(Tx, Pool)
    time.sleep(1)
    i += 1
    '''每十个交易打包一次'''
    if i % 10 == 0:
        block = Consensus.seal(Pool.pool[0:10], block_number = int(i/10 - 1), sealer_id = 0)
        Consensus.consensus(block,Chain)
        Storage.deleteTransactions(block,Pool)